<template>
  <div class="mainContent">
    <div class="headerTitle">综合监督管理平台</div>
    <!-- 项目选择切换 -->
    <div class="topProjectSelect">
      <div @click="goOthers('space')" class="top1"></div>
      <div @click="goOthers('dust')" class="top1 top2"></div>
      <div @click="goOthers('danger')" class="top1 top3"></div>
      <div @click="goOthers('')" class="top1 top4"></div>
      <div @click="goOthers('')" class="top1 bottom1"></div>
      <div @click="goOthers('')" class="top1 bottom1 bottom2"></div>
      <div @click="goOthers('factory')" class="top1 bottom1 bottom3"></div>
      <div @click="goOthers('')" class="top1 bottom1 bottom4"></div>
    </div>
    <!-- 左右侧边内容 -->
    <div class="content">
      <div class="commonStatic aside-left-show">
        <div class="innerTitle">
          <div class="descTitle">公共统计数据</div>
          <div class="detail">查看详情</div>
        </div>
        <div class="company" @click="showCompanyDialog">
          <div class="companyNum">{{ companysNumObj.companyAccess }}</div>
          <div class="companyNumR">
            +{{ publicNewDateMonthObj.companyAccessNew }}
          </div>
        </div>
        <div class="signal">
          <div class="signalNum">{{ companysNumObj.sceneInfo }}</div>
          <div class="signalNumR">
            +{{ publicNewDateMonthObj.sceneInfoNew }}
          </div>
        </div>
        <div class="equip">
          <div class="equipNum">{{ companysNumObj.deviceAccess }}</div>
          <div class="equipNumR">
            +{{ publicNewDateMonthObj.deviceAccessNew }}
          </div>
        </div>
        <div class="video">
          <div class="videoNum">{{ companysNumObj.videoAccess }}</div>
          <div class="videoNumR">
            +{{ publicNewDateMonthObj.videoAccessNew }}
          </div>
        </div>
      </div>
      <div class="equipStatus aside-left-show">
        <div class="detail">查看详情</div>
        <div class="num1">{{ equipStatusNum.equipOnLineNum }}</div>
        <div class="num2">{{ equipStatusNum.equipOutLineNum }}</div>
      </div>
      <div class="equipProblem aside-left-show">
        <div class="detail">查看详情</div>
        <div class="equipProblemList">
          <div class="top">
            <div class="left">设备名</div>
            <div class="right">故障状态</div>
          </div>
          <div
            :class="['bottom', { 'last-bottom': index === 4 }]"
            v-for="(item, index) in equipAlarmList"
            :key="item.id"
          >
            <div class="left">{{ item.equipName }}</div>
            <div class="right">{{ item.alarmReason }}</div>
          </div>
        </div>
      </div>
      <div class="videoAlarm aside-right-show">
        <div class="detail">查看详情</div>
        <div class="alarmWarningC">
          <div
            @click="chooseVideoA('')"
            :class="['alarmDesc', { active: isVideoAlarm === '' }]"
          >
            总览
          </div>
          <div
            @click="chooseVideoA('day')"
            :class="['alarmDesc', { active: isVideoAlarm === 'day' }]"
          >
            今日
          </div>
          <div
            @click="chooseVideoA('week')"
            :class="['alarmDesc', { active: isVideoAlarm === 'week' }]"
          >
            本周
          </div>
          <div
            @click="chooseVideoA('month')"
            :class="['alarmDesc', { active: isVideoAlarm === 'month' }]"
          >
            本月
          </div>
        </div>
        <div class="companyBox">
          <div
            class="companyList"
            v-for="(item, index) in companyVideoList"
            :key="index"
          >
            <div class="left">
              <div>{{ item.enterpriseName }}</div>
              <div class="time">{{ item.startTime }}</div>
            </div>
            <div class="right" @click="chooseBaoJ(item)">
              <img class="rightImg" src="@/assets/home/组 80@1x.png" alt="" />
            </div>
          </div>
        </div>
      </div>
      <div class="feelData aside-right-show">
        <div class="detail">查看详情</div>
        <div class="alarmWarningC">
          <div
            @click="chooseVideoF('')"
            :class="['alarmDesc', { active: isFeelDate === '' }]"
          >
            总览
          </div>
          <div
            @click="chooseVideoF('day')"
            :class="['alarmDesc', { active: isFeelDate === 'day' }]"
          >
            今日
          </div>
          <div
            @click="chooseVideoF('week')"
            :class="['alarmDesc', { active: isFeelDate === 'week' }]"
          >
            本周
          </div>
          <div
            @click="chooseVideoF('month')"
            :class="['alarmDesc', { active: isFeelDate === 'month' }]"
          >
            本月
          </div>
        </div>
        <div class="feelList" v-if="feelList.length > 0">
          <div
            :class="['feelItem', { feelItemBgc: feelIndex % 2 }]"
            v-for="(feelItem, feelIndex) in feelList"
            :key="feelItem.id"
          >
            <div class="name">{{ feelItem.enterpriseName }}</div>
            <div class="equipName">{{ feelItem.equipName }}</div>
            <div class="value">{{ feelItem.alarmValue }}</div>
          </div>
        </div>
        <div class="feelListEmpty" v-else>暂无数据</div>
      </div>
    </div>

    <div class="sheBeiZuo1dialogVisible" v-if="isDialogShow === 'home'">
      <div class="closeX">
        <img
          src="@/assets/factory/组 39@1x.png"
          alt=""
          @click="closeDialogShow"
        />
      </div>
      <div class="title">接入企业</div>
      <div class="table">
        <el-table
          :data="tableData"
          style="width: 100%; border: 'none'"
          :header-row-style="{
            backgroundColor: '#053A3B',
            color: '#2FC4B2',
            borderBottom: '1px solid #022627',
            borderRight: '1px solid #022627',
            height: '32px',
          }"
          :header-cell-style="{
            backgroundColor: '#053A3B',
            color: '#2FC4B2',
            borderBottom: '1px solid #022627',
            height: '32px',
            padding: '7px 0',
          }"
          :row-style="{
            backgroundColor: '#053A3B',
            color: '#2FC4B2',
            borderBottom: '1px solid #022627',
            height: '32px',
          }"
          :cell-style="{
            borderBottom: '1px solid #022627',
            height: '32px',
            padding: '7px 0',
          }"
        >
          <el-table-column
            header-align="center"
            prop="companyName"
            label="接入单位"
            width="220"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            header-align="center"
            prop="companyPrincipal"
            label="单位负责人"
            width="120"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            header-align="center"
            prop="companyPhone"
            label="负责人电话"
            width="180"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            header-align="center"
            prop="companyAddress"
            label="单位地址"
            width="300"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            header-align="center"
            prop="equipStatusName"
            label="单位状态"
            width="80"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.companyState === '营业'">{{
                scope.row.companyState
              }}</span>
              <span v-else style="color: #ff9c9c">{{
                scope.row.companyState
              }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="footerPage">
        <el-pagination
          :current-page="params.page"
          :page-size="10"
          background
          layout="prev, pager, next"
          :total="totalItemCount"
          @current-change="currentPage"
        />
      </div>
    </div>

    <div class="areaSelect"></div>
    <div class="footerNav"></div>
  </div>
</template>

<script>
import {
  companysNum,
  publicNewDateMonth,
  getEquipStatusNum,
  getEquipAlarm,
  companyDetails,
} from '@/api/home'
export default {
  name: 'homeVue',
  props: {},
  components: {},
  data() {
    return {
      isVideoAlarm: '',
      companyVideoList: [
        {
          enterpriseName: '长兴顺水铝合金门窗加工厂',
          startTime: '2024-01-13 12:59',
        },
        {
          enterpriseName: '长兴顺水铝合金门窗加工厂',
          startTime: '2024-01-13 12:59',
        },
        {
          enterpriseName: '长兴顺水铝合金门窗加工厂',
          startTime: '2024-01-13 12:59',
        },
        {
          enterpriseName: '长兴顺水铝合金门窗加工厂',
          startTime: '2024-01-13 12:59',
        },
        {
          enterpriseName: '长兴顺水铝合金门窗加工厂',
          startTime: '2024-01-13 12:59',
        },
        {
          enterpriseName: '长兴顺水铝合金门窗加工厂',
          startTime: '2024-01-13 12:59',
        },
        {
          enterpriseName: '长兴顺水铝合金门窗加工厂',
          startTime: '2024-01-13 12:59',
        },
        {
          enterpriseName: '长兴顺水铝合金门窗加工厂',
          startTime: '2024-01-13 12:59',
        },
      ],
      companysNumObj: {
        companyAccess: '-',
        deviceAccess: '-',
        sceneInfo: '-',
        videoAccess: '-',
      },
      publicNewDateMonthObj: {
        videoAccessNew: '-',
        deviceAccessNew: '-',
        sceneInfoNew: '-',
        companyAccessNew: '-',
      },
      equipStatusNum: {
        equipOnLineNum: '-',
        equipOutLineNum: '-',
      },
      equipAlarmList: [],
      isFeelDate: '',
      alarmDate: '',
      feelList: [],
      isDialogShow: '',
      tableData: [],
      totalItemCount: null,
      params: {
        pageNum: 1,
        pageSize: 10,
      },
    }
  },
  methods: {
    goOthers(path) {
      if (path !== this.$route.path.substring(1)) {
        this.$router.push(
          `/${path}`,
          () => {},
          () => {}
        )
      } else {
        this.$router.push('/home')
      }
    },
    chooseVideoA(params) {
      this.isVideoAlarm = params
    },
    chooseBaoJ(item) {
      console.log(item)
    },
    async companysNum(type) {
      const res = await companysNum({ type })
      this.companysNumObj = res.data
    },
    async publicNewDateMonth(type) {
      const res = await publicNewDateMonth({ type })
      this.publicNewDateMonthObj = res.data
    },
    async getEquipStatusNum() {
      const res = await getEquipStatusNum()
      this.equipStatusNum = res.data
    },
    async getEquipAlarm() {
      const res = await getEquipAlarm()
      this.equipAlarmList = res.data.slice(0, 5)
    },
    chooseVideoF(params) {
      this.isFeelDate = params
      this.getEquipAlarmDate(params)
    },
    async getEquipAlarmDate(date) {
      const res = await getEquipAlarm({ date })
      this.feelList = res.data.slice(0, 7)
    },
    showCompanyDialog() {
      this.isDialogShow = 'home'
      this.companyDetails(this.params)
    },
    closeDialogShow() {
      this.isDialogShow = ''
    },
    currentPage(pageNum) {
      const params = {
        identificationCode: 'all',
        pageNum: pageNum,
        pageSize: this.params.pageSize,
      }
      this.companyDetails(params)
    },
    async companyDetails(params) {
      const res = await companyDetails({
        identificationCode: 'all',
        pageNum: params.pageNum,
        pageSize: params.pageSize,
      })
      console.log(res)
      this.tableData = res.data
      this.totalItemCount = res.total
    },
  },
  created() {
    this.companysNum('all')
    this.publicNewDateMonth('all')
    this.getEquipStatusNum()
    this.getEquipAlarm()
    this.getEquipAlarmDate(this.alarmDate)

  },
  mounted() {},
  computed: {},
  filters: {},
}
</script>

<style scoped lang="scss">
.mainContent {
  width: 1920px;
  height: 1080px;
  position: relative;
  background-image: url('@/assets/common/WechatIMG2357.png');
  background-size: cover;
  background-repeat: no-repeat;
  position: relative;
}

.content {
  position: relative;
  .commonStatic {
    background-image: url('@/assets/home/组 48059@1x.png');
    position: absolute;
    background-size: cover;
    background-repeat: no-repeat;
    left: 11px;
    top: 72px;
    width: 420px;
    height: 282px;
    .innerTitle {
      color: #fff;
      background-image: url('@/assets/home/组 48060@1x.png');
      background-size: cover;
      background-repeat: no-repeat;
      width: 405px;
      box-sizing: border-box;
      height: 36px;
      font-size: 20px;
      font-weight: bold;
      position: relative;
      .descTitle {
        position: absolute;
        left: 15px;
        top: 7px;
      }
      .detail {
        color: #5de1d4;
        font-size: 12px;
        font-weight: bold;
        position: absolute;
        top: 5px;
        left: 327px;
        cursor: pointer;
      }
    }

    .company {
      background-image: url('@/assets/home/组 231@1x.png');
      background-size: cover;
      background-repeat: no-repeat;
      width: 180px;
      height: 92px;
      position: absolute;
      left: 20px;
      top: 58px;
      cursor: pointer;
      .companyNum {
        position: absolute;
        left: 74px;
        top: 15px;
        color: #fff;
        font-size: 28px;
        font-weight: bold;
      }
      .companyNumR {
        position: absolute;
        top: 2px;
        right: 6px;
        color: #103f3a;
        font-size: 12px;
        font-weight: bold;
      }
    }
    .signal {
      background-image: url('@/assets/home/组 48062@1x.png');
      background-size: cover;
      background-repeat: no-repeat;
      width: 180px;
      height: 92px;
      position: absolute;
      left: 220px;
      top: 58px;
      .signalNum {
        position: absolute;
        left: 74px;
        top: 15px;
        color: #fff;
        font-size: 28px;
        font-weight: bold;
      }
      .signalNumR {
        position: absolute;
        top: 2px;
        right: 6px;
        color: #103f3a;
        font-size: 12px;
        font-weight: bold;
      }
    }
    .equip {
      background-image: url('@/assets/home/组 229@1x (1).png');
      background-size: cover;
      box-sizing: border-box;
      background-repeat: no-repeat;
      background-position: center;
      width: 180px;
      height: 93px;
      position: absolute;
      left: 20px;
      top: 166px;
      .equipNum {
        position: absolute;
        left: 74px;
        top: 15px;
        color: #fff;
        font-size: 28px;
        font-weight: bold;
      }
      .equipNumR {
        position: absolute;
        top: 2px;
        right: 6px;
        color: #103f3a;
        font-size: 12px;
        font-weight: bold;
      }
    }
    .video {
      background-image: url('@/assets/home/组 222@1x (1).png');
      background-size: cover;
      box-sizing: border-box;
      background-repeat: no-repeat;
      background-position: center;
      width: 180px;
      height: 93px;
      position: absolute;
      left: 220px;
      top: 166px;
      .videoNum {
        position: absolute;
        left: 74px;
        top: 15px;
        color: #fff;
        font-size: 28px;
        font-weight: bold;
      }
      .videoNumR {
        position: absolute;
        top: 2px;
        right: 6px;
        color: #103f3a;
        font-size: 12px;
        font-weight: bold;
      }
    }
  }
  .equipStatus {
    background-image: url('@/assets/home/组 48063@1x.png');
    background-size: cover;
    background-repeat: no-repeat;
    width: 420px;
    height: 329px;
    position: absolute;
    left: 11px;
    top: 364px;
    .detail {
      color: #5de1d4;
      font-size: 12px;
      font-weight: bold;
      position: absolute;
      top: 5px;
      left: 327px;
      cursor: pointer;
    }
    .num1 {
      color: #fff;
      font-size: 32px;
      font-weight: bold;
      position: absolute;
      top: 86px;
      left: 65px;
      width: 100px;
      text-align: center;
    }
    .num2 {
      color: #fff;
      font-size: 32px;
      font-weight: bold;
      position: absolute;
      top: 86px;
      left: 240px;
      width: 100px;
      text-align: center;
    }
  }
  .equipProblem {
    background-image: url('@/assets/home/组 48063@1x01.png');
    background-size: cover;
    background-repeat: no-repeat;
    width: 420px;
    height: 333px;
    position: absolute;
    left: 11px;
    top: 703px;
    .detail {
      color: #5de1d4;
      font-size: 12px;
      font-weight: bold;
      position: absolute;
      top: 8px;
      left: 327px;
      cursor: pointer;
    }
    .equipProblemList {
      margin-top: 63px;
      padding: 0 15px;
      width: 390px;
      .left {
        width: 50%;
        text-align: center;
      }
      .right {
        width: 50%;
        text-align: center;
      }
      .top {
        padding-bottom: 13px;
        color: #fff;
        font-size: 14px;
        font-weight: bold;
        border-bottom: 1px solid #2fc4b2;
        display: flex;
        width: 390px;
      }
      .bottom {
        padding-bottom: 13px;
        color: #fff;
        font-size: 14px;
        border-bottom: 1px solid #2fc4b2;
        display: flex;
        width: 390px;
        margin-top: 12px;
        .right {
          color: #ffbd07;
        }
      }
      .last-bottom {
        border-bottom: none;
      }
    }
  }
  .videoAlarm {
    background-image: url('@/assets/home/Right_02@1x.png');
    background-size: cover;
    background-repeat: no-repeat;
    width: 420px;
    height: 523px;
    position: absolute;
    right: 12px;
    top: 72px;

    .detail {
      color: #5de1d4;
      font-size: 12px;
      font-weight: bold;
      position: absolute;
      top: 8px;
      left: 327px;
      cursor: pointer;
    }
    .alarmWarningC {
      box-sizing: border-box;
      width: 420px;
      padding-top: 32px;
      display: flex;
      justify-content: right;
      align-items: center;
      padding-right: 15px;
      font-size: 12px;
      margin-bottom: 20px;
      .alarmDesc {
        width: 40px;
        height: 20px;
        line-height: 20px;
        text-align: center;
        color: #59dace;
        border-radius: 2px;
        margin-left: 5px;
        background-color: #022627;
        border: 1px solid #59dace;
        cursor: pointer;
      }
      .active {
        background-color: #5de1d4;
        color: #022627;
      }
    }
    .companyBox {
      padding-left: 30px;
      padding-right: 14px;
      .companyList {
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #fff;
        margin-bottom: 20px;
        .right {
          .rightImg {
            width: 94px;
            height: 32px;
            cursor: pointer;
          }
        }
        .left {
          font-size: 14px;
          color: #fff;
          .time {
            color: #2fc4b2;
          }
        }
      }
    }
  }
  .feelData {
    width: 420px;
    height: 431px;
    background-image: url('@/assets/home/组 48075@1x.png');
    background-size: cover;
    background-repeat: no-repeat;
    position: absolute;
    right: 11px;
    top: 603px;
    .alarmWarningC {
      box-sizing: border-box;
      width: 420px;
      padding-top: 32px;
      display: flex;
      justify-content: right;
      align-items: center;
      padding-right: 15px;
      font-size: 12px;
      margin-bottom: 20px;
      .alarmDesc {
        width: 40px;
        height: 20px;
        line-height: 20px;
        text-align: center;
        color: #59dace;
        border-radius: 2px;
        margin-left: 5px;
        background-color: #022627;
        border: 1px solid #59dace;
        cursor: pointer;
      }
      .active {
        background-color: #5de1d4;
        color: #022627;
      }
    }
    .detail {
      color: #5de1d4;
      font-size: 12px;
      font-weight: bold;
      position: absolute;
      top: 4px;
      left: 327px;
      cursor: pointer;
    }
    .feelList {
      margin: 0 15px;
      margin-top: 45px;
      color: #fff;
      width: 390px;
      // padding-top: 16px;
      font-size: 14px;
      .feelItem {
        display: flex;
        width: 390px;
        height: 29px;
        line-height: 29px;
        margin-bottom: 16px;
        .name {
          width: 160px;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
          padding-left: 10px;
          text-align: center;
        }
        .equipName {
          width: 120px;
          margin: 0 10px 0 21px;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
          text-align: center;
        }
        .value {
          width: 50px;
          color: #de0202;
          text-align: center;
        }
      }
      .feelItemBgc {
        background-image: url('@/assets/home/矩形 451@1x.png');
        background-size: cover;
        background-repeat: no-repeat;
        width: 390px;
        height: 29px;
        line-height: 29px;
        z-index: -9999;
      }
    }
    .feelListEmpty {
      width: 100%;
      text-align: center;
      padding: 50px;
      color: #fff;
      box-sizing: border-box;
    }
  }
}
.headerTitle {
  background-image: url('@/assets/common/HEAD@1x (1).png');
  background-size: cover;
  background-repeat: no-repeat;
  position: relative;
  box-sizing: border-box;
  width: 1920px;
  height: 102px;
  text-align: center;
  padding-top: 9px;
  font-size: 40px;
  color: #fff;
  font-weight: bold;
  position: absolute;
  left: 0;
  top: 0;
}
.footerNav {
  background-image: url('@/assets/common/组 48054@1x.png');
  background-size: cover;
  background-repeat: no-repeat;
  position: relative;
  width: 1920px;
  height: 48px;
  position: absolute;
  left: 0;
  bottom: 0;
}
.areaSelect {
  background-image: url('@/assets/common/Buttom_Nav@1x.png');
  background-size: cover;
  background-repeat: no-repeat;
  position: relative;
  width: 684px;
  height: 30px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 52px;
}
.topProjectSelect {
  .top1 {
    width: 195px;
    height: 96px;
    position: absolute;
    top: 105px;
    left: 558px;
    background-image: url('@/assets/common/组 48064@1x.png');
    background-size: cover;
    background-repeat: no-repeat;
  }
  .top2 {
    left: 766px;
    background-image: url('@/assets/common/组 48065@1x.png');
  }
  .top3 {
    left: 973px;
    background-image: url('@/assets/common/组 48066@1x.png');
  }
  .top4 {
    left: 1190px;
    background-image: url('@/assets/common/组 48067@1x.png');
  }
  .bottom1 {
    top: 232px;
    background-image: url('@/assets/common/组 48068@1x.png');
  }
  .bottom2 {
    left: 766px;
    background-image: url('@/assets/common/组 48069@1x.png');
  }
  .bottom3 {
    left: 973px;
    background-image: url('@/assets/common/组 48063@1x.png');
  }
  .bottom4 {
    left: 1190px;
    background-image: url('@/assets/common/组 48070@1x.png');
  }
}
.sheBeiZuo1dialogVisible {
  width: 960px;
  height: 580px;
  background-image: url('@/assets/factory/矩形 201@1x.png');
  background-repeat: no-repeat;
  background-size: cover;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 350px;
  .closeX {
    display: flex;
    justify-content: right;
    padding: 4px;
    img {
      cursor: pointer;
    }
  }
  .title {
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    padding-left: 30px;
    margin-bottom: 8px;
    .subTitle {
      color: #9e9e9e;
      font-size: 12px;
    }
  }
  .table {
    padding: 0 30px;
    .el-table .warning-row {
      background-color: transparent;
      background: #022627 !important;
    }
    .el-table::before {
      display: none;
    }
  }
  .footerPage {
    width: 100%;
    text-align: center;
    margin: 10px auto 0;

    ::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
      background-color: #62c1b2 !important; // 进行修改选中项背景和字体
      color: #fff;
    }
  }
  .picBox {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 0 44px;
    margin-bottom: -31px;
    box-sizing: border-box;
    img {
      width: 429px;
      height: 214px;
      margin-bottom: 31px;
    }
  }
  ::v-deep .el-table__empty-block {
    background-color: #053a3b !important;
    border: none;
    .el-table__empty-text {
      color: #fff;
    }
  }
}
</style>
